import 'package:series_play/net/http_manager.dart';
import 'package:series_play/net/http_response.dart';
import 'package:series_play/utils/guestId_helper.dart';

import '../../bean/guest_login_data.dart';
import '../../bean/user_info_result_data.dart';

class AccountApi {
  static AccountApi instance = AccountApi._();

  factory AccountApi() => instance;

  AccountApi._();

  /// 游客登录
  Future<HttpResponse<GuestLoginData>> guestLogin() async {
    final device = await GuestIdHelper.getGuestId();
    return await HttpManager.instance.post(
      '/user/visitorLogin',
      data: {'device': device},
      fromJson: GuestLoginData.fromJson,
    );
  }

  /// 获取当前用户信息
  Future<HttpResponse<UserInfoResultData>> selfInfo() async {
    return await HttpManager.instance.post(
      '/user/info',
      fromJson: UserInfoResultData.fromJson,
    );
  }
}
